﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Text;

namespace ImportDB
{
    public class PlainDataFileBase
    {
        protected DataTable GetTable(string argConnectionString,string argSql)
        {
            OleDbConnection conn = new OleDbConnection(argConnectionString);
            conn.Open();
            var da = new OleDbDataAdapter(argSql, conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            AdjustColumnNames(dt);
            conn.Close();
            return dt;
        }
        protected void AdjustColumnNames(DataTable dt)
        {
            foreach (DataColumn col in dt.Columns)
            {
                col.ColumnName = col.ColumnName.Trim().Replace(' ', '_');
            }
        }
    }
}
